<?php
/**
 * @Author: Xu Liu email:2867557054@qq.com
 * @Date:   2016-12-15 13:31:33
 * @Last Modified by:   Xu Liu
 * @Last Modified time: 2017-07-17 12:29:27
 */
if (!defined('IN_ADMINCP') || !defined('IN_DISCUZ')) {
    exit('Access Denied');
}
class MfenxiangContrl
{
    public function index()
    {
        global $_G;
        $currentpge = $_GET['page']?intval($_GET['page']):1;
        $pagesize = 50;
        if (!isset($_GET['fx'])) {
            $counts    = C::t('#jameson_read#jamesonread_fx')->count_all_uid();
            $fenxiangs = C::t('#jameson_read#jamesonread_fx')->fetch_all_uid($pagesize*($currentpge-1), $pagesize);
            $pageshow  = multi($counts,$pagesize,$currentpge,ADMINSCRIPT.'?action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=jameson_read&pmod=jameson_read&contrl=mfenxiang&act=index');
        } elseif ($_GET['fx'] == 1 && !isset($_GET['fxuid'])) {
            $counts    = C::t('#jameson_read#jamesonread_fx')->count_all_tid();
            $fenxiangs = C::t('#jameson_read#jamesonread_fx')->fetch_all_tid($pagesize*($currentpge
                -1), $pagesize);
            $pageshow  = multi($counts,$pagesize,$currentpge,ADMINSCRIPT.'?action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=jameson_read&pmod=jameson_read&contrl=mfenxiang&act=index&fx=1');
        } elseif ($_GET['fxuid']) {
            $username  = DB::result_first('SELECT username FROM %t WHERE uid=%d', array('common_member', $_GET['fxuid']));
            $counts    = C::t('#jameson_read#jamesonread_fx')->count_byuid($_GET['fxuid']);
            $fenxiangs = C::t('#jameson_read#jamesonread_fx')->fetch_byuid($_GET['fxuid'], $pagesize*($currentpge-1), $pagesize);
            $pageshow  = multi($counts,$pagesize,$currentpge,ADMINSCRIPT.'?action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=jameson_read&pmod=jameson_read&contrl=mfenxiang&act=index&fx=1&fxuid=' . $_GET['fxuid']);
        }
        include template('jameson_read:mfenxiang_index');
    }
    public function delall()
    {
        if (FORMHASH != $_GET['formhash']) {
            cpmsg(lang('plugin/jameson_read', 'laiyuanfeifa'), 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=jameson_read&pmod=jameson_read&contrl=mfenxiang&act=index', 'error');
        }
        C::t('#jameson_read#jamesonread_fx')->clear();
        cpmsg(lang('plugin/jameson_read', 'gengxinchenggong'), 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=jameson_read&pmod=jameson_read&contrl=mfenxiang&act=index', 'succeed');
    }
}